﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using FJERP.Model;
using FJERP.BLL;

namespace FJERP
{
    public partial class WareHose_Show : System.Web.UI.Page
    {
        WareHoseBLL bll = new WareHoseBLL();
        protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack)
            {
                this.Repeater1.DataSource = bll.ShowWareHose();//获取数据
                this.Repeater1.DataBind();//绑定数据
                Label1.Text = bll.countWareHose().ToString();//总条数
            }
        }

        protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            string ename = e.CommandName;
            string WareHoseID = e.CommandArgument.ToString();
            switch(ename)
            {
                case"del":
                    if (bll.Del(Convert.ToInt32(WareHoseID)) > 0)
                    {
                        Response.Write("<script>alert('删除成功!!!')</script>");
                        this.Repeater1.DataSource = bll.ShowWareHose();//获取数据
                        this.Repeater1.DataBind();//绑定数据
                        Label1.Text = bll.countWareHose().ToString();//总条数
                    }
                    else
                    {
                        Response.Write("<script>alert('删除失败!!!')</script>");
                    }
                    break;
                case "upt":
                    Response.Redirect("WareHoseEdit.aspx?id=" + WareHoseID);
                    break;

            }
        }

        protected void Unnamed_ServerClick(object sender, EventArgs e)
        {
            string WareHose_Name = this.WareHose_Name.Value;
            this.Repeater1.DataSource = bll.SeaarchWareHose(WareHose_Name);//获取数据源
            this.Repeater1.DataBind();//绑定数据源
            Label1.Text = bll.countWareHose().ToString();//总条数

        }

      

       
    }
}